unit fmBalance;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB,
  cxDBData, MemDS, DBAccess, MSAccess, StdCtrls, Buttons, Mask,
  cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxGrid, dxPSGlbl, dxPSUtl, dxPSEngn,
  dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
  dxPSEdgePatterns, dxPSPDFExportCore, dxPSPDFExport, cxDrawTextUtils,
  dxPSPrVwStd, dxPSPrVwAdv, dxPSPrVwRibbon, dxPScxEditorProducers,
  dxPScxExtEditorProducers, dxPScxPageControlProducer, dxPSCore,
  dxPScxCommon, dxPScxGrid6Lnk, cxDBLookupComboBox, cxCurrencyEdit;

type
  TBalanceForm = class(TForm)
    tvBalance: TcxGridDBTableView;
    glBalance: TcxGridLevel;
    cxGrid1: TcxGrid;
    grp1: TGroupBox;
    lbl3: TLabel;
    medtAccount: TMaskEdit;
    btnOK: TBitBtn;
    btnExport: TBitBtn;
    msqryBalance: TMSQuery;
    srcBalance: TDataSource;
    tvBalanceAccountNo: TcxGridDBColumn;
    tvBalanceLastBalance: TcxGridDBColumn;
    tvBalanceRealMoney: TcxGridDBColumn;
    tvBalanceBalance: TcxGridDBColumn;
    tvBalanceDealTime: TcxGridDBColumn;
    dxComponentPrinter: TdxComponentPrinter;
    dxComponentPrinterLink1: TdxGridReportLink;
    tblAccount: TMSTable;
    srcAccount: TDataSource;
    procedure btnOKClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnExportClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  BalanceForm: TBalanceForm;

implementation

uses
  fmMain;

{$R *.dfm}

procedure TBalanceForm.btnOKClick(Sender: TObject);
var
  vAccountNo, vSQL: string;
begin
   vAccountNo := Trim(medtAccount.Text);
   if vAccountNo = '' Then
      vSQL := 'Select * from TD_AccountBalance '
   else
      vSQL := 'Select * from TD_AccountBalance where AccountNo=' + vAccountNo;

   msqryBalance.Close;
   msqryBalance.SQL.Text := vSQL;
   msqryBalance.Open;
end;

procedure TBalanceForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   tblAccount.Close;
   Action := caFree;
end;

procedure TBalanceForm.btnExportClick(Sender: TObject);
begin
   dxComponentPrinter.Preview(True);
end;

procedure TBalanceForm.FormCreate(Sender: TObject);
begin
   tblAccount.Open;
end;

end.
